﻿package mortal.game.view.guildNew.building
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.common.display.*;

    public class GuildNewBuildCell extends GSprite
    {
        protected var _btn:GLoadedButton;
        protected var _levelNum:BitmapNumberText;
        protected var _nameBg:GBitmap;
        protected var _tip:GTextFiled;
        private var _dataInfo:TGuildStructureConfig;

        public function GuildNewBuildCell()
        {
            this.mouseEnabled = true;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._btn = UIFactory.gLoadedButton(ImagesConst.GuildNBuildingBNBg_upSkin, 0, 0, 131, 46, this);
            this._btn.label = "";
            this._levelNum = UIFactory.bitmapNumberText(24, 8, "GuildNewBuildingNum2.png", 21, 24, -10, this, 13, 1);
            this._levelNum.text = "16";
            this._nameBg = UIFactory.gBitmap(ImagesConst.GuildNBuildingBN0, 47, 12, this);
            this._tip = UIFactory.gTextField("" + Language.getString(71420), 1, 41, 130, 20, this, GlobalStyle.textFormatHong.center().setBold(true));
            this._btn.mouseEnabled = false;
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._btn = null;
            this._levelNum = null;
            this._nameBg = null;
            this._tip = null;
            return;
        }// end function

        public function updateInfo(param1:TGuildStructureConfig, param2:int) : void
        {
            var _loc_3:int = 0;
            if (this._nameBg)
            {
                this._nameBg.dispose();
            }
            this._nameBg = UIFactory.gBitmap(ImagesConst["GuildNBuildingBN" + param2], 47, 12, this);
            this._dataInfo = param1;
            if (param1)
            {
                this._levelNum.text = param1.structureLevel.toString();
                _loc_3 = GuildBuildingConfig.instance.getNextBuildingLvNeedGuildLv2(Cache.instance.guild.selfGuildInfo.baseInfo.level, param1.structureType, param1.structureLevel);
                if (_loc_3 == -1)
                {
                    this._tip.text = "" + Language.getString(71421);
                }
                else
                {
                    this._tip.text = Language.getStringByParam(71422, _loc_3);
                }
            }
            return;
        }// end function

        public function get dataInfo() : TGuildStructureConfig
        {
            return this._dataInfo;
        }// end function

    }
}
